package com.silverbox.sweeporder.service.alipay;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import com.silverbox.core.result.CoreResponse;
import com.silverbox.core.result.CoreResponse.StatusInfo;
import com.silverbox.shopper.dubboApi.alipay.dto.UndiscountWaimaiDTO;
import com.silverbox.shopper.entity.AlipayApplyAuthToken;
import com.silverbox.shopper.entity.AlipayTradeRecord;
import com.silverbox.shopper.entity.Machine;
import com.silverbox.sweeporder.controller.pay.entryvo.AlipayEntryVO;
import com.silverbox.sweeporder.controller.pay.entryvo.PayTradeEntryVO;
import com.silverbox.sweeporder.controller.pay.entryvo.VipPayEntryDto;
import com.silverbox.sweeporder.controller.pay.entryvo.WechatPayEntryVO;
import com.silverbox.sweeporder.controller.pay.vo.AlipayVO;
import com.silverbox.sweeporder.controller.pay.vo.WechatPayVO;
import com.silverbox.sweeporder.controller.waimai.outvo.WaimaiTradeInfo;
import com.silverbox.waimai.entity.extend.WaimaiExtend;

public interface SweepAlipayService {

    /**
     * 获取店铺授权令牌
     *
     * @param token
     * @return
     */
    AlipayApplyAuthToken getAlipayApplyAuthToken(AlipayApplyAuthToken token);

    /**
     * 计算不打折金额
     *
     * @param storeId
     * @param outSupportId
     * @param waimai
     * @param priceFlag
     * @return
     */
    Map<String, Object> getUnDiscountAmount(Integer storeId, Long outSupportId, UndiscountWaimaiDTO waimai,
                                            boolean priceFlag);

    /**
     * 刷新授权令牌
     *
     * @param token
     * @return
     */
    AlipayApplyAuthToken flushAuthToken(AlipayApplyAuthToken token);

    /**
     * 修改店铺授权令牌
     *
     * @param token
     * @return
     */
    int updateAlipayApplyAuthToken(AlipayApplyAuthToken token);

    /**
     * 保存交易记录
     *
     * @param record
     * @return
     */
    int saveAlipayTradeRecord(AlipayTradeRecord record);

    /**
     * 查询店铺机器
     *
     * @param storeId
     * @return
     */
    List<Machine> getMachineByStoreId(Integer storeId);

    /**
     * 批量保存交易渠道
     *
     * @return
     */
    void insertTradeFundChannelByBatch(String orderNum, String tradeNo, Integer storeId, Integer shopperId,
                                       String platform, Date date, String fundBillList);

    /**
     * 拼接订单中计算不打折金额所需信息
     *
     * @param waimai
     * @return
     */
    public UndiscountWaimaiDTO getUndiscountWaimaiDTO(WaimaiExtend waimai);

    /**
     * 扫码下单支付宝支付
     *
     * @return
     */
    CoreResponse<AlipayVO> alipay(HttpServletResponse response,AlipayEntryVO alipayEntry);
    /**
     * 扫码下单支付宝支付异步回调
     *
     * @param
     */
    void payNotify(Map<String,Object> params);

    /**
     * 扫码下单会员卡支付
     * @param orderNum
     * @param uid
     * @param buyerId
     * @return
     */
    CoreResponse<StatusInfo> vipPay(VipPayEntryDto vipPayEntry);

    /**
     * 扫码下单支付宝支付撤销等待支付订单
     *
     * @param storeId
     * @param orderNum
     * @param outTradeNo
     * @param cancelJSON
     */
    void cancelAlipayOrder(Integer storeId, String orderNum, String outTradeNo, String cancelJSON);

    /**
     * 微信支付
     * @return
     */
    CoreResponse<WechatPayVO> wechatPay(HttpServletResponse response,WechatPayEntryVO wechatPayEntry);

    /**
     * 申请订单退款
     * @param orderNum
     * @param refundReason
     */
    boolean updateAlipayRefund(String orderNum, String refundReason);

    /**
     * 获取订单支付交易信息
     * @return
     */
    WaimaiTradeInfo getPayTradeInfo(PayTradeEntryVO payTradeEntryVO);
}
